//提币
<template>
    <div class="coin-out">
        <div style="margin-bottom: 10px;display: flex;justify-content: space-between;align-items: center;">
            <!--开始日期：{{startTm}} 结束日期：{{endTm}}-->
            <div>日期：
                <el-date-picker
                        v-model="value1"
                        type="daterange"
                        @change="getDate"
                        value-format="timestamp"
                        range-separator="至"
                        start-placeholder="开始日期"
                        :picker-options="endDateOpt"
                        end-placeholder="结束日期">
                </el-date-picker>
            </div>
            <div>
                <el-button @click="getUserWithdrawHis2" type="primary">查询</el-button>
            </div>
        </div>
        <div v-if="false">

            <!-- 交易记录表格 -->
            <b-table responsive="md" hover :fields="fields" :items="items" class="in-table">
                <template slot="txid" slot-scope="data">
                    <p style="max-width:200px">{{data.item.txid}}</p><!-- txid -->
                    <!-- <div v-if="data.item.status !=2" @click="showTxid(data.item.txid)" class="txid-btn"></div> -->
                </template>
                <template slot="address" slot-scope="data">
                    <p>{{data.item.address}}</p><!-- 地址 -->
                </template>
                <template slot="coinType" slot-scope="data">
                    <p>{{data.item.coinType}}</p><!-- 币种 -->
                </template>
                <template slot="value" slot-scope="data">
                    <p>{{data.item.value}}</p><!-- 数量 -->
                </template>
                <template slot="fee" slot-scope="data">
                    <p>{{data.item.fee}}</p><!-- 手续费 -->
                </template>
                <template slot="createTm" slot-scope="data">
                    <span>{{getLocalTime(data.item.createTm)}}</span><!-- 创建时间 -->
                </template>
                <template slot="status" slot-scope="data">
                    <span :style="{color:transformStatus(data.item.status).color}">{{transformStatus(data.item.status).text}}</span>
                    <!-- 确认中 -->
                </template>
                <template slot="address,txid" slot-scope="data">
                    <div>{{getLocalTime(data.item.createTm)}}</div><!-- 第二行 -->
                    <template slot="txid" slot-scope="data">
                        <p style="max-width:200px">{{data.item.txid}}</p><!-- txid -->
                        <!-- <div v-if="data.item.status !=2" @click="showTxid(data.item.txid)" class="txid-btn"></div> -->
                    </template>
                </template>
            </b-table>
            <div class="page-pagination">
                <div style="float: left;margin-left: 30px">合计：{{sumAmount}}</div>
                <b-pagination align="right" :total-rows="total" v-model="currentPage" :per-page="10">
                </b-pagination>
            </div>
        </div>
        <div class="" style="">
            <div class="toubu">

                <div style="padding-left:0;float:left;width:20%">{{$t('u_sj')}}</div>
                <!-- <th width="220px">{{$t('u_zrqbdz')}}</th> -->
                <div style="width: 10%;float:left;">{{$t('h_bz')}}</div>
                <div style="width: 15%;float:left;">{{$t('tbsl')}}</div>
                <!-- <th>{{$t('u_qrcs')}}</th> -->

                <div style="width: 12%;float:left;">{{$t('u_zt')}}</div>
                <div style="width: 15%;float:left;">{{$t('tbbeizhu')}}</div>
                <div style="width: 25%;float:left;">{{$t('u_shouxufei')}}</div>

            </div>
            <div class="con" v-for="(list,index) in items"
                 :key="index"
                 style="">


                <div style="width:20%;float:left;">{{getLocalTime(list.createTm)}}</div>

                <!-- <td style="padding-right:1.8rem">
                  <div>{{list.address}}</div>
                </td> -->
                <div style="float:left;width: 10%;">{{list.coinType}}</div>
                <div style="float:left;width: 15%;">{{list.value}}{{list.coinType}}</div>
                <!-- <td>{{list.comfirmCount}}</td> -->
                <div style="float:left;width: 12%;" v-if="list.status=='0'" :style="{color:list.color}">确认中</div>
                <div style="float:left;width: 12%;" v-if="list.status=='1'" :style="{color:list.color}">成功</div>
                <div style="float:left;width: 12%;" v-if="list.status=='2'" :style="{color:list.color}">失败</div>
                <div style="float:left;width: 12%;" v-if="list.status=='3'" :style="{color:list.color}">审核驳回</div>
                <div style="float:left;width: 15%;">{{list.remark}}</div>
                <div style="float:left;width: 25%;">{{list.fee}}{{list.coinType}}
                    <!-- <div v-if="list.status != $t('shibai')"  class="txid-btnn">{{list.fee}}</div> -->

                </div>
                <div class="sanjiao" style="cursor:pointer;" @click="chuxianhuaxizhi(index)">▼</div>

                <div style="float:left;">{{$t('u_tbdz')}}{{' '}}{{list.address}}</div>
                <div class="allert" style="" @click="gotoall(list.coinType,list.txid)">{{$t('haxizhi')}}{{' '}}<span>{{list.txid}}</span>
                </div>

            </div>
            <div class="page-pagination" style="    margin-top: 20px;margin-right: 31px;">
                <div style="float: left;">合计：{{sumAmount}}</div>
                <b-pagination align="right" :total-rows="total" v-model="currentPage" :per-page="rows">
                </b-pagination>
            </div>
        </div>

    </div>
</template>

<script>
    import {mapActions} from "vuex";
    import {getLocalTime} from "../../assets/js/common";
    import mixins from '../../assets/js/mixin'
    import {dateFormat} from "../../assets/js/common.js";
    export default {
        mixins: [mixins],
        data() {
            return {
                msg: "提币",
                panduan: null,
                fields: [
                    {key: 'createTm', label: this.$t('u_zcsj')},
                    {key: 'coinType', label: this.$t('bizhong')},

                    {key: 'value', label: this.$t('u_sl')},
                    {key: 'fee', label: this.$t('u_shouxufei')},
                    {key: 'status', label: this.$t('u_zt')},
                    {key: 'remark', label: this.$t('u_beiz')},
                    {key: 'address', label: this.$t('u_jsdz')},
                    {key: 'txid', label: this.$t('u_jlid')},
                ],
                items: [],
                userData: null,
                isHavePwd: true,
                ifDisabled: false,
                btnText: this.$t('u_hqyzm'),
                timer: null,
                phone: "",
                isActive: 0,
                coinList: null,
                coinVal: "",
                coinType: "",
                coinAddress: "",
                remark: "",
                passWorde: "",
                mgsCode: "",
                once: false,
                currentPage: 1,
                total: 1,
                page: 1,
                rows: 10,
                minCoin: 0,
                maxCoin: 0,
                coinFee: 0,
                coinType_query: "",
                onceFlag: true,
                ifHkt: true,
                startTm: (new Date().getTime() - 3600 * 1000 * 24 * 7),
                endTm: new Date().getTime(),
                value1: [(new Date().getTime() - 3600 * 1000 * 24 * 7), new Date()],
                endDateOpt: {
                    disabledDate(time) {
                        return time.getTime() > new Date();
                    }
                },
                sumAmount:0

            };
        },
        methods: {
            getLocalTime,
            init() {
                this.coinVal = "";
                this.coinType = "";
                this.coinAddress = "";
                this.remark = "";
                this.passWorde = "";
                this.mgsCode = "";
            },
            // pageList: function (page) {//分页
            //     this.getUserCoinRecord(page);
            // },
            getDate(e) {
                console.log(e);
                console.log(this.value1);
                this.startTm = this.value1[0]
                this.endTm = this.value1[1]
            },
            getDate2() {

            },
            getUserWithdrawHis2() {
                this.currentPage = 1
                this.getUserCoinRecord()
            },
            chuxianhuaxizhi(index) {//▲▼
                let con = document.getElementsByClassName('con')[index];
                // let sanjiao = document.getElementById('sanjiao').innerHTML;

                // console.log("yuan"+sanjiao)
                if (con.style.height == 50 + 'px') {
                    con.style.height = 100 + 'px'
                    document.getElementsByClassName('sanjiao')[index].innerHTML = '▲';
                    // sanjiao == '▲'
                } else if (con.style.height != 50 + 'px') {
                    con.style.height = 50 + 'px'
                    document.getElementsByClassName('sanjiao')[index].innerHTML = '▼';
                }


            },
            gotoall(cointype, url) {

                switch (cointype) {
                    case 'BTC':
                        return window.open('https://www.blockchain.com/btc/tx/' + url);
                        break;
                    case 'LTC':
                        return window.open('http://explorer.litecoin.net/search?q=' + url);
                        break;
                    case 'ETH':
                        return window.open('https://etherscan.io/tx/' + url);
                        break;
                    case 'EOS':
                        return window.open('https://eospark.com/tx/' + url);
                        break;
                    case 'USDT':
                        return window.open('https://www.blockchain.com/btc/tx/' + url);
                        break;
                    case 'ETC':
                        return window.open('http://gastracker.io/tx/' + url);
                        break;
                    case 'STC':
                        return window.open('http://block.starchain.one/transactiondetail/' + url);
                        break;
                    case 'UEC':
                        return window.open('http://block.starchain.one/transactiondetail/' + url);
                        break;

                    default:
                        window.open('https://etherscan.io/tx/' + url);
                }
            },
            activeChange(i) {
                this.isActive = i;
                this.getCoinConfig(this.coinList[this.isActive].coinType);
                this.getUserCoinRecord();
                if (i == 0) {
                    this.ifHkt = true
                } else {
                    this.ifHkt = false
                }
            },
            getUserCoinRecord() {
                this.$http.get('/nb-web/api/coin/user/record/list', {
                    params: {
                        index: this.currentPage,
                        rows: this.rows,
                        startTime: this.startTm,
                        endTime: this.endTm,
                        opType: 2,
                        // coinType: this.coinList[this.isActive].coinType
                    }
                }).then(res => {
                    if (res.data.code == '001') {
                        this.items = res.data.result.data;
                        this.total = res.data.result.total || 1;
                        this.sumAmount = res.data.result.subs || 0;

                    }
                })
            },
            transformStatus(val) {
                var val = val.toString();
                switch (val) {
                    case '0':
                        return {
                            text: this.$t('querenz'),
                            color: "orange"
                        }
                        break;
                    case '1':
                        return {
                            text: this.$t('chenggong'),
                            color: 'green'
                        }
                        break;
                    case '2':
                        return {
                            text: this.$t('shibai'),
                            color: 'red'
                        }
                        break;
                    default:
                        return val;
                        break;
                }
            },
            showTxid(id) {
                this.$swal(id, {
                    icon: '/static/img/tan_chuang.png'
                });
            },
            ...mapActions(['coinTabActiveChange', 'ifLoadingChange'])
        },
        created() {
            this.getUserCoinRecord();
        },
        watch: {
            currentPage(newval) {

                this.getUserCoinRecord();
            }
        },
    };
</script>


<style lang="scss" scoped>

    .table-hover thead tr th {
        border-top: 0;
        border-bottom: 1px solid rgba(153, 167, 200, 0.2) !important;
        font-family: PingFangSC-Medium;
        font-size: 14px;
        color: #99A7C8;
        letter-spacing: 0;
        text-align: left;
    }

    .table th {
        border-top: 0 !important;
    }

    .hkt-msg {
        font-size: 18px;
        color: #666;
        margin-top: 20px;
        margin-bottom: 50px;
    }

    .coin-out {
        padding-top: 30px;
        padding-left: 30px;
        padding-right: 30px;
        min-height: 600px;
        width: 100%;

        table {
            thead {
                tr th {
                    font-weight: normal;

                    &:nth-child(1) {
                        min-width: 180px;
                    }

                    &:nth-child(2) {
                        min-width: 170px;
                    }

                    &:nth-child(3) {
                        min-width: 100px;
                    }

                    &:nth-child(4) {
                        min-width: 150px;
                    }

                    &:nth-child(5) {
                        min-width: 100px;
                    }

                    &:nth-child(6) {
                        min-width: 100px;
                    }

                    &:nth-child(7) {
                        min-width: 120px;
                    }

                    &:nth-child(8) {
                        min-width: 100px;
                    }

                    &:nth-child(9) {
                        min-width: 80px;
                    }
                }
            }

            tbody {
                tr td {
                    padding: 0.35rem 0.75rem;
                    font-size: 14px;
                    line-height: 30px;
                    font-family: PingFangSC-Medium;
                    font-size: 14px;
                    color: #546EAA;
                    letter-spacing: 0;

                    p {
                        // word-break:break-all
                    }
                }
            }
        }

        .coin-out-tips-text {
            margin: 0px 0 18px;
            color: #666;
        }

        .user-card {
            > div {
                height: 86px;
                padding: 13px 0 13px 10px;
                margin-bottom: 8px;
                position: relative;
            }

            img {
                width: 60px;
                height: 60px;
                float: left;
            }

            .user-card-text {
                float: left;
                margin-left: 15px;

                p:nth-child(1) {
                    line-height: 32px;
                    color: #333;
                    font-size: 16px;
                }

                p:nth-child(2) {
                    line-height: 29px;
                    color: #999;
                    font-size: 12px;
                }
            }

            .user-card-state {
                position: absolute;
                top: 0;
                right: 0;
                padding-right: 25px;

                p {
                    color: #315dcf;
                    line-height: 86px;
                    font-size: 14px;
                    cursor: pointer;
                }
            }
        }

        .user-card-phone {
            background-color: #eaffe0;
        }

        .user-card-iden {
            background-color: #ffefef;
        }

        .user-card-login {
            background-color: #d6f4fe;
        }

        .user-card-pay {
            background-color: #f3f2ff;
        }

        //提币
        .user_coinin_chosen {
            background: #f8f8f8;
            border: 1px solid #eee;
            // min-height: 345px;
            margin-bottom: 30px;
        }

        .coinin_chosen {
            padding: 25px 20px;
            display: flex;

            span {
                width: 80px;
                line-height: 24px;
            }

            ul {
                flex: 1;
            }

            li {
                font-size: 14px;
                line-height: 24px;
                color: #333333;
                float: left;
            }

            .chosen-item {
                margin: 0 10px;
                padding: 0 10px;
                cursor: pointer;
                list-style: none;

                &:hover,
                &.active {
                    color: #fff;
                    background: #2d6df0;
                    border-radius: 2px;
                }
            }
        }

        .qrcode {
            img {
                display: block;
                margin: 0 auto;
                width: 160px;
            }
        }

        .pay-address {
            p {
                margin-top: 23px;
                line-height: 24px;
                margin-bottom: 30px;
                font-size: 14px;
                color: #333;
                width: 100%;
                text-align: center;
            }

            .pay-address-btn {
                width: 161px;
                height: 45px;
                text-align: center;
                line-height: 45px;
                background: #2d6df0;
                color: #fff;
                font-size: 16px;
                border-radius: 20px;
                margin: 0 auto;
            }
        }

        .chosen-line {
            width: 100%;
            height: 30px;
            border-bottom: 1px dashed #d2d2d2;
        }

        .chosen-tips-text {
            padding: 15px 15px;

            p {
                font-size: 12px;
                color: #999;
            }
        }

        .balance-text {
            font-size: 14px;
            color: #333333;
            padding: 10px 20px;

            b {
                font-size: 24px;
            }
        }

        // 表单
        .input-item {
            display: flex;
            padding: 10px;
            font-size: 14px;

            .item-name {
                width: 80px;
                margin-right: 10px;
                line-height: 38px;
                text-align: right;
            }

            .item-state {
                line-height: 38px;
                text-align: left;
            }

            .item-val {
                flex: 1;
                font-size: 14px;
            }
        }

        .submit-btn {
            flex: 1;
            margin: 0;
        }

        .img-code {
            margin-left: 5px;
            height: 100%;
            width: 106px;
            border: 1px solid #868e96;
            border-radius: 0.25rem;

            img {
                display: block;
                width: 104px;
                height: 36px;
            }
        }

        .phone-code {
            margin-left: 5px;
        }

        .coin-out-tips-text {
            margin-top: 10px;
            margin-bottom: 40px;

            p {
                font-size: 12px;
                line-height: 18px;
                color: #999999;
            }
        }

        .txid-btn {
            width: 60px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            border-radius: 4px;
            background-color: #2d6df0;
            color: #ffffff;
            cursor: pointer;
        }
    }

    .in-table {
        width: 100%;
        overflow: auto;
    }

    .in-table table {
        width: 100%;
        min-width: 850px;
        // border-top: 1px #eee solid;
    }

    .in-table table tr {
        border-bottom: 1px solid rgba(153, 167, 200, 0.2);
    }

    .in-table thead tr th {
        font-family: PingFangSC-Medium !important;
        font-size: 14px !important;
        color: #99A7C8 !important;
        letter-spacing: 0 !important;
    }

    //    .in-table tr th:nth-child(6){
    //      padding-right:0;
    //      text-align: right!important;
    //    }
    .in-table tr th,
    .in-table tr td {
        padding: 10px;
        // border-bottom: 1px #eee solid;
        font-weight: normal;
        font-size: 14px;
    }

    .in-table tr th,
    .in-table tr td {
        // border-bottom: 1px #eee solid;
    }

    .in-table tr td div {
        line-height: 20px;
    }

    .tbody {
        font-family: PingFangSC-Medium;
        font-size: 16px;
        color: #99A7C8;
        letter-spacing: 0;
        color: #5291FF
    }

    .toubu {
        font-family: PingFangSC-Medium;
        font-size: 14px;
        color: #546EAA;
        letter-spacing: 0;
        height: 36px;
        line-height: 1.8;
        border-bottom: 1px solid rgba(153, 167, 200, 0.2);
    }

    .con {

        width: 960px;
        height: 50px;;
        border-bottom: 1px solid rgba(153, 167, 200, 0.2);
        overflow: hidden;

        div {
            font-family: PingFangSC-Medium;
            font-size: 14px;
            color: #546EAA;
            letter-spacing: 0;
            line-height: 3.4
        }
    }

    .allert {
        float: right;
        cursor: pointer;
    }

    .allert span:hover {
        color: #3498db
    }
    .page-pagination{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
</style>
